
ITEM.base = "base_weapon"
ITEM.class = "bow"
ITEM.label = "Bow"
ITEM.description = "A primitive bow made from vine,sap,and wood."
ITEM.weight = 8
ITEM.model = "models/props_debris/wood_board02a.mdl"
ITEM.icon = "wintersurvival/icon_bow"

ITEM.holdtype = "smg"
ITEM.viewmodel = {
	{ //top
		bone = "ValveBiped.Bip01_L_Hand",
		model = "models/props_debris/wood_board02a.mdl",
		size = Vector(.5,.5,.35),
		pos = Vector(-1,-6,9),
		ang = Angle(-30,-65,180),
	},
	{ //bottom
		bone = "ValveBiped.Bip01_L_Hand",
		model = "models/props_debris/wood_board02a.mdl",
		size = Vector(.5,.5,.35),
		pos = Vector(-1,-6,-9),
		ang = Angle(30,-65,180),
	},
	{ //string
		bone = "ValveBiped.Bip01_L_Hand",
		model = "models/props_debris/wood_board02a.mdl",
		size = Vector(.05,.05,.51),
		pos = Vector(-3.3,-9.5,0),
		ang = Angle(0,-65,180),
		color = Color(0,0,0,255),
	},
	{ //arrow
		bone = "ValveBiped.Bip01_L_Hand",
		model = "models/mixerman3d/other/arrow.mdl",
		pos = Vector(-4.5,-12,3),
		ang = Angle(0,55,0),
		color = Color(255,255,255,255),
		req = "arrow",
	},
}
ITEM.cooldown = 1

//Weapon

function ITEM:onThink(pl)
end

function ITEM:onPrimary(pl)
	local GM = gmod.GetGamemode()
	local itemtab,inv = self:getDatTab(pl)
	
	if CLIENT or not itemtab then
		return
	end
	
	if (itemtab.lastused + self.cooldown) < CurTime() and pl:WSHas("arrow") then
		local ent = ents.Create("ws_arrow")
		ent:SetPos(pl:GetShootPos())
		ent:SetAngles(pl:EyeAngles())
		ent:SetModel("models/mixerman3d/other/arrow.mdl")
		ent:SetOwner(pl)
		timer.Simple(1,function()
			if IsValid(ent) then
				ent:SetOwner()
			end
		end)
		ent:Spawn()
		ent:GetPhysicsObject():ApplyForceCenter(pl:GetAimVector() * math.pow(35,3)) //Why are we using math.pow when we can use an accent? Meh.
		
		pl:WSGive("arrow",-1)
	end
end

function ITEM:onSecondary(pl)
end
